package com.baizhi.jishi.service.impl;

import com.baizhi.jishi.dao.UserDao;
import com.baizhi.jishi.entity.User;
import com.baizhi.jishi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;
    @Override
    public String login(String username, String password, String code, HttpSession session) {
        String code2 = (String) session.getAttribute("validationCode");
        if (code2!=null&&code2.equals(code)){
            User user = userDao.login(username, password);
            if (user!=null){
                session.setAttribute("user",user);
                return "buju";
            }else {
                return "login";
            }
        }else {
            return "login";
        }
    }
}
